package org.liukai.ems.dao;

import org.liukai.ems.entity.po.Emp;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @create EmpDao.java 10:54
 * 
 * @author liukai
 * @date 2015/12/11
 */

@Repository
public class EmpDao extends SqlSessionDaoSupport{
    public List<Emp> queryEmpList() {
        return getSqlSession().selectList("emp.queryEmpList");//该字符串等于Emp.xml中的namespace.id
    }

    public void addEmp(Emp emp) {
        getSqlSession().insert("emp.addEmp" ,emp);
    }

    public Emp queryEmpByEmpId(String empId) {
        return getSqlSession().selectOne("emp.queryEmpByEmpId", Integer.parseInt(empId));
    }

    public void deleteEmp(String empId) {
        getSqlSession().delete("emp.deleteEmp", Integer.parseInt(empId));
    }

    public void updateEmp(Emp emp) {
        getSqlSession().update("emp.updateEmp", emp);
    }

}
